{% extends "feedback_base.html" %}
{% load debate_tags i18n static %}

{% block sub-title %}{% blocktrans trimmed %}<span id="c_breaking">{{ c_breaking }}</span> marked as breaking{% endblocktrans %}{% endblock %}

{% block page-alerts %}

  {% tournamenturl 'options-tournament-section' section='feedback' as option_url %}
  {% if pref.feedback_paths == 'minimal' %}
    {% blocktrans trimmed asvar p1 %}
      The current <a href="{{ option_url }}" class="alert-link">feedback configuration</a> allows and expects only chairs to submit feedback (on their panellists and trainees).
    {% endblocktrans %}
  {% elif pref.feedback_paths == 'with-p-on-c' %}
    {% blocktrans trimmed asvar p1 %}
      The current <a href="{{ option_url }}" class="alert-link">feedback configuration</a> allows and expects both chairs and panellists to submit feedback on each other, and also chairs to submit feedback on trainees.
    {% endblocktrans %}
  {% elif pref.feedback_paths == 'with-t-on-c' %}
    {% blocktrans trimmed asvar p1 %}
      The current <a href="{{ option_url }}" class="alert-link">feedback configuration</a> allows and expects both panellists and trainees to submit feedback on chairs, and chairs to submit feedback on every other member of the panel (including trainees).
    {% endblocktrans %}
  {% elif pref.feedback_paths == 'all-adjs' %}
    {% blocktrans trimmed asvar p1 %}
      The current <a href="{{ option_url }}" class="alert-link">feedback configuration</a> allows and expects all adjudicators (including trainees) to submit feedback on every other member of the panel (including trainees).
    {% endblocktrans %}
  {% endif %}
  {% include "components/explainer-card.html" with type="info" %}

  {% if nadjs_outside_range > 0 %}
    {% tournamenturl 'options-tournament-section' section='feedback' as feedback_settings_url %}
    {% blocktrans trimmed with min_score=pref.adj_min_score max_score=pref.adj_max_score count nadjs_outside_range=nadjs_outside_range asvar message %}
      There is <strong>{{ nadjs_outside_range }} adjudicator</strong> with
      a score <strong>outside the permitted range</strong> of adjudicator
      scores, which is currently set as {{ min_score }} to {{ max_score }}.
      This can cause adjudicator auto-allocation to behave in unexpected ways.
      If you'd like to use a wider score range, you can configure this in
      <a href="{{ feedback_settings_url }}" class="alert-link"> feedback
      settings</a>.
    {% plural %}
      There are <strong>{{ nadjs_outside_range }} adjudicators</strong> with
      scores <strong>outside the permitted range</strong> of adjudicator
      scores, which is currently set as {{ min_score }} to {{ max_score }}.
      This can cause adjudicator auto-allocation to behave in unexpected ways.
      If you'd like to use a wider score range, you can configure this in
      <a href="{{ feedback_settings_url }}" class="alert-link"> feedback
      settings</a>.
    {% endblocktrans %}
    {% include "components/alert.html" with type="warning" %}
  {% endif %}
  {{ block.super }}
{% endblock %}

{% block content %}

  <div class="row">
    {% include "overview_breakdowns.html" %}
  </div>

  {{ block.super }}

  {% include "overview_modals.html" %}

{% endblock %}

{% block js %}

  <script>
    var setBreakingURL = '{% tournamenturl 'adjfeedback-set-adj-breaking-status' %}';
  </script>
  {{ block.super }}
  <script>
    // Actions for the table elements
    $(document).ready(function(){
      $(".edit-base-score a").each( function() {
        $(this).click( function() {
          var adj_id = parseInt($(this).attr("data-target"));
          var adj_score = $(this, "span").text();
          $("#id_adj_id").val(adj_id); // Updating form ID reference
          $("#id_base_score").prop('placeholder', adj_score); // updating the form's table
          $('#edit-base-score').modal();
        });
      });
      $(".edit-note a").each( function() {
        $(this).click( function() {
          var adj_id = parseInt($(this).attr("data-target").split("===")[0]);
          var adj_note = $(this).attr("data-target").split("===")[1];
          $("#id_note").val(adj_note);
          $("#id_adj_id_note").val(adj_id);
          $('#edit-note').modal();
        });
      });
    });
  </script>

{% endblock js %}
